$(function ()
{
    findById();
})

function findById()
{
    let id = sessionStorage.getItem("ptid");

    let data = publivAjax('/back/productType/findById', {id: id}, 'get');

    if (data != null)
    {
        let model = data.model;
        $("#productType").val(model.productType);
        $("#enType").val(model.enType);
        $("#isShow").val(model.isShow);
        $("#recommend").val(model.recommend);
    }
}

function save()
{
    let msg = {}
    let id = sessionStorage.getItem("ptid");

    msg.id = id;
    msg.productType = $.trim($("#productType").val());
    msg.enType = $.trim($("#enType").val());
    msg.isShow = $.trim($("#isShow").val());
    msg.recommend = $.trim($("#recommend").val());

    let data = publivAjax('/back/productType/edit', msg, 'post');

    if (data.count == 1)
    {
        $('#b-right').load('/back/productType/productTypeList.html');
    }
    else
    {
        alert("修改失败！");
    }
}